<template>
  <div class="HomeView">
    <el-container>
      <el-header height="60px">
        <div class="left">
          <p style="font-size: 20px; color: #fff; font-family: 'AA'">后台管理系统</p>
        </div>
        <div class="right">
          <el-button type="info" @click="loginOut">退出</el-button>
        </div>
      </el-header>
      <el-container style="height: calc(100vh - 60px)">
        <el-aside :width="isCollapse ? '64px' : '300px'">
          <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
            <div class="Switch" @click="isCollapse = !isCollapse">
              <el-icon
                style="color: #909399"
                :class="
                  isCollapse ? 'iconfont icon-hamburger-menu' : 'iconfont icon-hamburger-menu'
                "
              ></el-icon>
            </div>
          </el-radio-group>
          <Menu background-color="#333744" text-color="#fff" :isCollapse="isCollapse"></Menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const isCollapse = ref(true)
import Menu from '@/components/menu/indexView.vue'

import { useLoginStore } from '@/stores/login'
import { useRouter } from 'vue-router'

const loginStore = useLoginStore()
const router = useRouter()

function loginOut() {
  loginStore.token = ''
  router.replace('/LoginVue')
}

//  将  扁平数组  转护为 树形结构

// function fn(arr: any, list: any) {
//   arr.forEach((item: any) => {
//     if (!item.children) {
//       list.push(item.name)
//     } else {
//       list.push(item.name)
//       fn(item.children, list)
//     }
//   })
//   return list
// }

// console.log(111111, fn(arr, []))

</script>

<style scoped>
@import url('../../FontCss/IconFontCss.css');
.el-radio-group {
  width: 100%;
  height: 50px;
  font-size: 16px;
}
.el-aside {
  transition: width 0.5s;
}

.el-menu {
  width: 100%;
}
.el-header {
  width: 100%;
  background-color: #373f41;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
::v-deep .el-sub-menu {
  background: #333744;
  color: #fff;
}
::v-deep .el-menu-item-group {
  background: #333744;
  color: #fff;
}
::v-deep .el-aside {
  background: #333744;
}
.Switch {
  width: 100%;
  height: 100%;
  display: flex;
  color: #fff;
  align-items: center;
  justify-content: center;
}
</style>
